package application.model.rpc
{
	import com.ericfeminella.rpc.AMFPHPRemoteGateway;
	
	import flash.events.Event;
	
	import mx.rpc.IResponder;
	
	public class Gateway extends AMFPHPRemoteGateway implements IResponder
	{
		public static const RESULT:String = "result";
		public static const FAULT:String = "fault";
		
		private var _data:Object;
		
		public function get data():Object
		{
			return _data;
		}
		
		public function set data(value:Object):void
		{
			_data = value;
		}
		
		public function Gateway(gatewayURI:String, classPath:String)
		{
			super( gatewayURI );
			this.addResponder( this );
			this.remoteServiceClass( classPath );
			_data = new Object();
		}
		
		public function result(data:Object):void
		{
			this.data = data;
			dispatchEvent( new Event(Gateway.RESULT) );
		}
		
		public function fault(info:Object):void
		{
			this.data = info;
			dispatchEvent( new Event(Gateway.FAULT) );
		}
	}
}